Skip to content

Conversation

@haukex
Copy link

@haukex haukex commented Nov 4, 2025

Hi, I would like to propose that the transaction() helper gets an additional argument max_tries (perhaps even with a default value) to prevent infinite loops, as can happen fairly easily by accident:

vk = Valkey()
def incr(pipe: Pipeline):
    next_value = int(pipe.get('key')) + 1
    pipe.multi()
    vk.set('key', next_value)  # WRONG!
vk.transaction(incr, 'key', max_tries=100)  # would eventually raise error instead of infinite loop

If you like this change, I can also suggest some documentation updates etc. if you like.

@mkmkme
Copy link
Collaborator

mkmkme commented Nov 4, 2025

Hey,

Thanks for your contribution! Could you please sign off your commit? You can find how to do it here, in the failed check report.

@mkmkme
Copy link
Collaborator

mkmkme commented Nov 4, 2025

Also I would really appreciate if you could provide a test for your changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants